<?php
/**
 * Date utility class
 *
 * @author André Silva
 */
class Date {
	/**
	 * Get the localized date string, based in a format given.
	 * @param string $format
	 * @param mixed $param
	 * @return string
	 */
	public static function format($format, $param = null) {
		if ($param === null) {
			$param = time();
		}
		if (!is_int($param)) {
			$param = strtotime($param);
		}
		return strftime($format, $param);
	}

	/**
	 * Get the date string registered in CERBERUS_DATE_FORMAT
	 * @param mixed $param
	 * @return string
	 */
	public static function toDate($param = null) {
		return self::format(CERBERUS_DATE_FORMAT, $param);
	}

	/**
	 * Get the datetime string registered in CERBERUS_DATE_FORMAT
	 * @param mixed $param
	 * @return string
	 */
	public static function toDateTime($param = null) {
		return self::format(CERBERUS_DATE_FORMAT.' %T', $param);
	}

	/**
	 * Get the time string
	 * @param mixed $param
	 * @return string
	 */
	public static function toHour($param = null) {
		return self::format('%T', $param);
	}

	/**
	 * Get the localized day of week
	 * @param mixed $param
	 * @return string
	 */
	public static function toDayOfWeek($param = null) {
		return self::format('%A', $param);
	}
}

//4926
//168,17
//139,01
//188,96 - 3 ~ 6
//204,96 - 7 ~ 12
//175,80
?>


